import request from '@/utils/request'

/**
 *
 * @returns 获取组织架构数据
 */
const getDepartment = () => {
  return request({
    url: '/company/department'
  })
}

/**
 *
 * @returns 获取部门负责人数据
 */
const getManagerList = () => {
  return request({
    url: '/sys/user/simple'
  })
}

/**
 *
 * @param {*} data
 * @returns 新增组织
 */
const addDepartment = (data) => {
  return request({ method: 'post', url: '/company/department', data })
}

/**
 *
 * @param {*} id
 * @returns 获取部门详情
 */
const getDepartmentDetail = (id) => {
  return request({ url: `/company/department/${id}` })
}

/**
 *
 * @param {*} data
 * @returns 更新部门
 */
const updateDepartment = (data) => {
  return request({ method: 'put', url: `/company/department/${data.id}`, data })
}

/**
 *
 * @param {*} id
 * @returns 删除部门
 */
const delDepartment = (id) => {
  return request({ method: 'delete', url: `/company/department/${id}` })
}

export {
  getDepartment,
  getManagerList,
  addDepartment,
  getDepartmentDetail,
  updateDepartment,
  delDepartment
}
